package com.ruoyi.web.controller.ring.app;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ring.domain.dto.GeneralSecondDTO;
import com.ruoyi.ring.service.IFoodInfoSecondService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 饮食二级页 app
 */
@Slf4j
@RestController
@RequestMapping("/ring/app/food_info_second")
public class FoodInfoSecondController extends BaseController
{
    @Resource
    private IFoodInfoSecondService foodInfoService;

    /**
     * 查询日历数据列表-app
     */
    @GetMapping("/query-calendar-list")
    public AjaxResult queryCalendarList(GeneralSecondDTO secondDTO){
        long userId = SecurityUtils.getUserId();
        log.info("查询日历数据列表: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(foodInfoService.queryCalendarList(secondDTO));
    }
    /**
     * 二级页 饮食
     */
    @GetMapping("/query-food-info")
    public AjaxResult queryFoodInfo(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("饮食: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(foodInfoService.queryFoodInfo(secondDTO));
    }
    /**
     * 二级页 能量平衡
     */
    @GetMapping("/query-energy-balance")
    public AjaxResult queryEnergyBalance(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("能量平衡: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(foodInfoService.queryEnergyBalance(secondDTO));
    }

    /**
     * 三级页 饮食统计
     */
    @GetMapping("/query-food-list")
    public AjaxResult queryFoodList(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("饮食统计: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return foodInfoService.queryFoodList(secondDTO);
    }
}
